package top.loonglove.bean;

import top.loonglove.status.ElementType;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author 向贵龙
 * @date 2021/7/12
 * markDown标签超类
 */
public abstract class AbstractElement implements Serializable {
    /**
     * 标签内容
     */
    protected String value;
    /**
     * 标签类型
     */
    protected ElementType type;

    public AbstractElement(String value, ElementType type) {
        this.value = value;
        this.type = type;
    }

    public AbstractElement(String value) {
        this.value = value;
    }

    public AbstractElement() {
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return value;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof AbstractElement)) {
            return false;
        }
        AbstractElement that = (AbstractElement) o;
        return Objects.equals(getValue(), that.getValue()) && Objects.equals(type, that.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(getValue(), type);
    }

    public ElementType getType() {
        return type;
    }

    public void setType(ElementType type) {
        this.type = type;
    }
}
